package cn.tedu.ivos2.dict.controller;

import cn.tedu.ivos2.base.response.JsonResult;
import cn.tedu.ivos2.dict.pojo.dto.DictQuery;
import cn.tedu.ivos2.dict.pojo.dto.DictSaveParam;
import cn.tedu.ivos2.dict.pojo.vo.DictVO;
import cn.tedu.ivos2.dict.service.DictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/dict")
public class DictController {
    @Autowired
    DictService  dictService;
    @GetMapping("search")
    public JsonResult search(DictQuery  dictQuery) {
        List<DictVO> vo = dictService.search(dictQuery);
        return JsonResult.ok(vo);
    }
    @PostMapping("save")
    public JsonResult save(DictSaveParam dictSaveParam){
        dictService.save(dictSaveParam);
        return JsonResult.ok();
    }
    @PostMapping("delete/{id}")
    public JsonResult delete(@PathVariable Long id){
        dictService.delete(id);
        return JsonResult.ok();
    }
}
